package com.bit.talkoftoday;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;

public class DiaryTimeOptionActivity extends Activity implements OnClickListener, OnTimeChangedListener {
	private int mHour,mMinute;
	private TimePicker timpicker;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_diary_time_option);
		
		findViewById(R.id.btn_option_save2).setOnClickListener(this);
		findViewById(R.id.btn_option_cancle2).setOnClickListener(this);
		
		timpicker = (TimePicker)findViewById(R.id.datePicker2);
		timpicker.setOnTimeChangedListener(this);
		mHour=timpicker.getCurrentHour();
		mMinute=timpicker.getCurrentMinute();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.diary_time_option, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_option_save2:
			Intent intent = new Intent();
			intent.putExtra("minute",mMinute);
			intent.putExtra("hour",mHour);
			setResult(RESULT_OK,intent);
			finish();
			break;
		case R.id.btn_option_cancle2:
			setResult(RESULT_CANCELED);
			finish();
			break;
		}
	}

	@Override
	public void onTimeChanged(TimePicker arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		mHour = arg1;
		mMinute = arg2;
	}

}
